/*
 * @Author: xiaosihan
 * @Date: 2024-08-25 19:05:06
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-08-25 20:58:41
 */

import { first, last } from "lodash";
import { observable, configure } from "mobx";
configure({ enforceActions: "never" });

const homeStore = observable(
  {
    path: "",
    setPath(path: string) {
      this.path = path;
    },

    //角色
    role: "2",
    setRole(role: string) {
      this.role = role;
    },

    //所有动画
    animas: [] as Array<string>,
    setAnimas(animas: Array<string>) {
      this.animas = [...animas];
      const fristAnima = last(animas);
      fristAnima && this.setAnima(fristAnima);
    },

    // 当前动画
    anima: "",
    setAnima(anima: string) {
      this.anima = anima;
      this.setPath(
        `${location.origin}${location.pathname}#/modelView/${this.role}/${this.anima}`
      );
    },
  },
  {},
  { deep: false }
);

export default homeStore;
